package com.xdjd.mobile.system.config;


import com.xdjd.mobile.business.entity.param.wxpay.IWXPayDomain;
import com.xdjd.mobile.business.entity.param.wxpay.WXPayConfig;
import com.xdjd.mobile.business.entity.param.wxpay.WXPayDomainSimpleImpl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.InputStream;

@Component
@ConfigurationProperties(prefix = "wxpay")
public class WxpayExtConfig extends WXPayConfig {

    //配置信息改由dubbo从member返回
    // 公众号ID
    private String appID;
    //商户号
    private String mchID;
    //退款接口需要配置证书,暂时不配置
    //private String certPath = "";
    private String appSecret;
    private String key;
    private String notifyUrl;

    @Override
    public String getAppID() {
        return appID;
    }

    public void setAppID(String appID) {
        this.appID = appID;
    }

    @Override
    public String getMchID() {
        return mchID;
    }

    public void setMchID(String mchID) {
        this.mchID = mchID;
    }

    public String getAppSecret() {
        return appSecret;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    @Override
    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    /**
     * 证书二级制字节流
    private byte[] certData;

    private WxpayExtConfig() throws Exception {
        File file = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    }*/



    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }


    public InputStream getCertStream() {
//        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
//        return certBis;
        return null;
    }

    public IWXPayDomain getWXPayDomain() {
        return WXPayDomainSimpleImpl.instance();
    }


//    public String getCertPath() {
//        return certPath;
//    }
//
//    public void setCertPath(String certPath) {
//        this.certPath = certPath;
//    }


//    public void setAppSecret(String appSecret) {
//        this.appSecret = appSecret;
//    }

//    public byte[] getCertData() {
//        return certData;
//    }
//
//    public void setCertData(byte[] certData) {
//        this.certData = certData;
//    }
}
